<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>作品列表 - 今日头条(用户)</title>
    <meta th:replace="~{/head/head_include ::  title}"/>
    <script type="text/javascript">
        /* 作品收藏 要发送ajax请求 */
        function collectInsert(){
            console.log("collectInsert,添加");
            if(!window.confirm('确认要操作吗?')) {
                return false;
            }
            var workId = $("#workIdSpan").html();
            $.post(rootPath + "/head/work/collectInsertSubmit", {
                "entity.workId": workId
            }, function(result){
                console.info("返回结果:" , result);
                alert(result.info)
            }, "json");
            return false
        }
    </script>
</head>
<body>
<meta th:replace="~{/head/head_include ::  header}"/>
<div class="container">
    <div class="row">
        <div class="col-sm-8 col-sm-offset-1 main">
            <h2 class="col-sm-10 col-sm-offset-1 form-signin-heading text-center">查看作品</h2>
            <a class="btn btn-primary ml-2" href="#" onclick="return collectInsert()">收藏</a>
            <a th:href="@{/head/work/commentInsert(entity.workId=${one.id})}" target="_blank" class="btn btn-primary ml-2">评论</a>
            <div class="form-group row">
                <label for="email" class="col-sm-2 control-label">Id</label>
                <div class="col-sm-8">
                    <span id="workIdSpan" th:text="${one?.id }"></span>
                </div>
            </div>
            <div class="form-group row">
                <label for="email" class="col-sm-2 col-form-label">名称:</label>
                <div class="col-sm-8">
                    <span th:text="${one.name}"></span>
                </div>
            </div>
            <div class="form-group row">
                <label for="email" class="col-sm-2 col-form-label">浏览量:</label>
                <div class="col-sm-8">
                    <span th:text="${one.viewCount}"></span>
                </div>
            </div>
            <div class="form-group row">
                <label for="email" class="col-sm-2 col-form-label">创建时间:</label>
                <div class="col-sm-8">
                    <span th:text="${#dates.format(one.createTime,'yyyy-MM-dd HH:mm:ss')}"></span>
                </div>
            </div>
            <div class="form-group row">
                <label for="email" class="col-sm-2 col-form-label">更新时间:</label>
                <div class="col-sm-8">
                    <span th:text="${#dates.format(one.updateTime,'yyyy-MM-dd HH:mm:ss')}"></span>
                </div>
            </div>
            <div class="form-group row">
                <label for="email" class="col-sm-2 col-form-label">内容:</label>
                <div class="col-sm-8">
                    [(${one?.content})]
                </div>
            </div>
        </div>
    </div>

    <div class="row show" id="ansSelList">
        <div class="col-md-11 col-sm-offset-1">
            <h4 class="sub-header">评论列表</h4>
            <div class="table-responsive mt-2">
                <table class="table table-striped table-hover">
                    <thead>
                    <tr>
                        <th>标题</th>
                        <th width="400">内容</th>
                        <th>作者</th>
                        <th>创建时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <th:block th:each="oneTemp : ${commentList }">
                        <tr>
                            <td th:text="${oneTemp.name }"></td>
                            <td>[(${oneTemp?.content})]</td>
                            <td th:text="${oneTemp.users?.nickName }"></td>
                            <td th:text="${#dates.format(oneTemp.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                        </tr>
                    </th:block>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<meta th:replace="~{/head/head_include ::  footer}"/>
</body>
</html>